package com.ybkj.o2o.zhuanxian.service.impl;

import com.ybkj.o2o.zhuanxian.entity.OrderReview;
import com.ybkj.o2o.zhuanxian.mapper.OrderReviewMapper;
import com.ybkj.o2o.zhuanxian.service.OrderReviewService;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

@Service
public class DefaultOrderReviewService implements OrderReviewService {

  @Autowired
  private OrderReviewMapper orderReviewMapper;

  @Override
  public int insert(OrderReview orderReview) {

    return orderReviewMapper.insert(orderReview);
  }

  @Override
  public OrderReview findByOrderIdAndAppKey(Long orderId, String appKey) {
    List<OrderReview> list = orderReviewMapper.findByOrderIdAndAppKey(orderId, appKey);
    return CollectionUtils.isEmpty(list) ? null : list.get(0);
  }

  @Override
  public void deleteById(Long id, String appKey) {
    orderReviewMapper.deleteById(id, appKey);
  }

  @Override
  public OrderReview findOne(Long id, String appKey) {
    return orderReviewMapper.findOne(id, appKey);
  }

  @Override
  public Long countByDriver(Long driverId, String appKey) {
    return orderReviewMapper.countByDriver(driverId, appKey);
  }

  @Override
  public List<OrderReview> findByDriver(Long driverId, Integer limit, Integer rows, String appKey) {
    return orderReviewMapper.findByDriver(driverId, limit, rows, appKey);
  }


}
